package com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor;

import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Cancel;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.ConsumerKey;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.ConsumerSecret;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.MaxLength;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Name;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Password;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Quota;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.RecordId;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Save;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Sender;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.Tag;
import com.google.code.irouter.portal.client.dashboard.main.center.managers.library.browser.consumer.editor.form.User;
import com.gwtext.client.core.Ext;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.layout.AnchorLayoutData;

public final class Form extends FormPanel {

	public Form() {
		super();
		this.setId(Form.class.getName());
		
		this.setBaseCls("x-plain");
		this.setPaddings(15);
		this.add(new Name(), new AnchorLayoutData("95%"));
		this.add(new Sender(), new AnchorLayoutData("95%"));
		this.add(new ConsumerKey(), new AnchorLayoutData("95%%"));
		this.add(new ConsumerSecret(), new AnchorLayoutData("95%%"));
		this.add(new User(), new AnchorLayoutData("95%%"));
		this.add(new Password(), new AnchorLayoutData("95%%"));
		this.add(new MaxLength(), new AnchorLayoutData("95%%"));
		this.add(new Quota(), new AnchorLayoutData("95%%"));
		this.add(new Tag(), new AnchorLayoutData("95%%"));
		this.add(new RecordId());
		this.addButton(new Save());
		this.addButton(new Cancel());
	}
	
	public void edit(String recordId, String name, String sender, String consumerKey, String consumerSecret, String user, String password, int maxLength, int quota, String tag) {
		((RecordId) Ext.getCmp(RecordId.class.getName())).setValue(recordId);
		((Name) Ext.getCmp(Name.class.getName())).setValue(name);
		((Sender) Ext.getCmp(Sender.class.getName())).setValue(sender);
		((ConsumerKey) Ext.getCmp(ConsumerKey.class.getName())).setValue(consumerKey);
		((ConsumerSecret) Ext.getCmp(ConsumerSecret.class.getName())).setValue(consumerSecret);
		((User) Ext.getCmp(User.class.getName())).setValue(user);
		((Password) Ext.getCmp(Password.class.getName())).setValue(password);
		((MaxLength) Ext.getCmp(MaxLength.class.getName())).setValue(maxLength);
		((Quota) Ext.getCmp(Quota.class.getName())).setValue(quota);
		((Tag) Ext.getCmp(Tag.class.getName())).setValue(tag);
	}
	
}
